//
//  PictureCell.m
//  cascade-realm
//
//  Created by QSC on 2024/5/17.
//

#import "PictureCell.h"
#import "CALoginController.h"
@interface PictureCell()
@property (nonatomic,strong)UIButton * btn;

@end

@implementation PictureCell
- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {

        UIImageView *imagev = [[UIImageView alloc]initWithFrame:self.bounds];
        _imageV = imagev;
        _imageV.contentMode = UIViewContentModeScaleToFill;
        _imageV.userInteractionEnabled = YES;
        
        _imageV.clipsToBounds = YES;

        [self addSubview:imagev];
        
        //底部按钮
        UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
        [self addSubview:btn];
        [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
        self.btn = btn;
        btn.frame = CGRectMake(0, ScreenH - 150, ScreenW, 150);
        
    }
    return self;
}

- (void)setIndex:(NSInteger)index{
    _index = index;
    
}


//设置图片
- (void)setImageSource:(id)imageSource
{
    _imageSource = imageSource;
    
    if ([imageSource isKindOfClass:[UIImage class]]) {
        self.imageV.image = imageSource;
    }
}


- (void)btnClick{
        
    
    if (self.index == 2) {
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"didShowStartPage"];

        [UIApplication sharedApplication].keyWindow.rootViewController = [CALoginController new];
    }else{
        !self.nextBlock?:self.nextBlock();
    }
        
    
    
    
    
    
}


@end
